<?php
/**
 * request model class
 *
 * @author raphael seebacher <raphasee@ee.ethz.ch>
 * @version 0.01
 */
class request extends model {
    protected $properties = NULL;

    protected static function stripslashes_deep($value) {
        if (is_array($value)) {
            return array_map(Array(self, 'stripslashes_deep'), $value);
        }
        else {
            return stripslashes($value);
        }
    }

    protected static function remove_magic_quotes() {
        if (get_magic_quotes_gpc()) {
            $_REQUEST = self::stripslashes_deep($_REQUEST);
        }
    }

    public function __construct() {
        self::remove_magic_quotes();
        $this->set_properties($_REQUEST);
    }

    protected function set_properties($properties) {
        if (!is_array($properties)) {
            return false;
        }

        if (is_array($this->properties)) {
            $this->properties = array_merge($this->properties, $properties);
        }
        else {
            $this->properties = $properties;
        }

        return true;
    }

    protected function set_property($key, $value) {
        return ($this->properties[$key] = $value);
    }

    public function property_exists($key) {
        return array_key_exists($key, $this->properties);
    }

    public function get_properties() {
        return $this->properties; 
    }

    public function get_property($key) {
        if (isset($this->properties[$key])) {
            return $this->properties[$key];
        }

        return NULL;
    }

    public function get_request_string() {
        return $this->get_property('request');
    }
}
?>